package de.teamskill.pux.samples.image;

import java.io.File;

import de.teamskill.pux.engine.AbstractNode;
import de.teamskill.pux.engine.Network;
import de.teamskill.pux.library.gui.ImageDisplayNode;
import de.teamskill.pux.library.image.ImageBlurNode;
import de.teamskill.pux.library.image.ImageLoaderNode;
import de.teamskill.pux.library.util.SplitNode;

public class ImageBlurTest {

	private Network net;

	public ImageBlurTest() {
		setup();
		start();
	}

	/**
	 * setup
	 * 
	 */
	private void setup() {
		net = new Network();
		String imageFile = null;
		try {
			imageFile = new File("test.png").getCanonicalPath();
		} catch (Exception e) {
			e.printStackTrace(System.err);
			System.exit(1);
		}

		AbstractNode image = new ImageLoaderNode().addToNetwork(net).makeStartupNode();
		image.configure(ImageLoaderNode.CONFIG_IMAGEURI, imageFile);

		AbstractNode split = new SplitNode("Image Split", 2, false).addToNetwork(net);
		AbstractNode displayBefore = new ImageDisplayNode("Before", false).addToNetwork(net);
		AbstractNode blur = new ImageBlurNode("Blur", false).addToNetwork(net);
		AbstractNode displayAfter = new ImageDisplayNode("After", false).addToNetwork(net);

		net.connect(image, "IMAGE", split, "IN");
		net.connect(split, "OUT1", displayBefore, "IN");
		net.connect(split, "OUT2", blur, "IN");
		net.connect(blur, "OUT", displayAfter, "IN");
	}

	/**
	 * start
	 * 
	 */
	private void start() {
		net.start();
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		new ImageBlurTest();
	}

}
